#include <stdio.h>
#include <stdlib.h>

typedef struct body
{
	float3 pos;
	float3 vel;
	float mass;
} body;

typedef struct bodyList
{
	float4* pos;
	float3* vel;
	int size;
} bodyList;

bodyList* readBodyList()
{
	// read in number of bodies
	int num_bodies;
	scanf("%d\n", &num_bodies);

	// allocate body list
	bodyList* bl = (bodyList*)malloc(sizeof(bodyList));
	//bl->bodies = (body*)malloc(num_bodies*sizeof(body));
	bl->pos = (float4*)malloc(num_bodies*sizeof(float4));
	bl->vel = (float3*)malloc(num_bodies*sizeof(float3));
	bl->size = num_bodies;

	// read in bodies
	int i;
	for (i = 0; i != num_bodies; ++i)
	{
		float4* pos = &bl->pos[i];
		float3* vel = &bl->vel[i];
		scanf("%f %f %f %f %f %f %f\n", &pos->x, &pos->y, &pos->z,
			&vel->x, &vel->y, &vel->z, &pos->w);
	}

	return bl;
}

void freeBodyList(bodyList* bl)
{
	free(bl->pos);
	free(bl->vel);
	free(bl);
}
